<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/UserHome.Master" CodeBehind="Manage.aspx.vb" Inherits="LEAD.Manage" 
    title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">


    <tr>
        <td>
    <form id="form1" runat="server">            

<script type="text/javascript">
    function ToggleDiv(Flag) {
        if (Flag == "first") {
            document.getElementById('dvUsers').style.display = 'block';
            document.getElementById('dvArticle').style.display = 'none';
            document.getElementById('dvPermissions').style.display = 'none';
            document.getElementById('dvComments').style.display = 'none';
            document.getElementById('dvLbl').style.display = 'none';
        }
        else
        if (Flag == "second") {
            document.getElementById('dvUsers').style.display = 'none';
            document.getElementById('dvArticle').style.display = 'block';
            document.getElementById('dvPermissions').style.display = 'none';
            document.getElementById('dvComments').style.display = 'none';
            document.getElementById('dvLbl').style.display = 'none';
        }
        else
        if (Flag == "third") {
            document.getElementById('dvUsers').style.display = 'none';
            document.getElementById('dvArticle').style.display = 'none';
            document.getElementById('dvPermissions').style.display = 'block';
            document.getElementById('dvComments').style.display = 'none';
            document.getElementById('dvLbl').style.display = 'none';
        }
        else
        if (Flag == "fourth") {
            document.getElementById('dvUsers').style.display = 'none';
            document.getElementById('dvArticle').style.display = 'none';
            document.getElementById('dvPermissions').style.display = 'none';
            document.getElementById('dvComments').style.display = 'block'; 
            document.getElementById('dvLbl').style.display = 'none';
        }
        else
        {
            document.getElementById('dvUsers').style.display = 'none';
            document.getElementById('dvArticle').style.display = 'none';
            document.getElementById('dvPermissions').style.display = 'none';
            document.getElementById('dvComments').style.display = 'none'; 
            document.getElementById('dvLbl').style.display = 'block';
        }
    }
        </script>
        <asp:Button ID="btn" runat="server" Text="Manage Users"
            OnClientClick="ToggleDiv('first');return false;" ForeColor="#990000" 
        Enabled="False" />
         
        <asp:Button ID="Button1" runat="server" Text="Manage Articles" 
        OnClientClick="ToggleDiv('second');return false;" ForeColor="#990000" 
        Enabled="False" />

        <asp:Button ID="Button2" runat="server" Text="Manage Permissions"
            OnClientClick="ToggleDiv('third');return false;" ForeColor="#990000" 
        Enabled="False" />
         
        <asp:Button ID="Button3" runat="server" Text="Manage Comments" 
        OnClientClick="ToggleDiv('fourth');return false;" ForeColor="#990000" 
        Enabled="False" />
    <asp:HyperLink ID="HyperLink2" runat="server" ForeColor="Red" 
        NavigateUrl="~/MonitorPoints.aspx" Enabled="False">Monitor Poings here</asp:HyperLink>
    <br /><br />

<div id="dvLbl" style="display: none;">
        <asp:Label ID="Label1" runat="server" Visible="false" Text="Label"></asp:Label>
</div>

<div id="dvUsers" style="display: none;">
    <a style="font-size:large; color:Gray; text-align:center; ">Edit/Delete Users</a>
                            <asp:GridView ID="gvUserName" runat="server" AllowPaging="True" 
                            AllowSorting="True" DataSourceID="SqlDataSource1" HorizontalAlign="Center" 
                            DataKeyNames="Userid">
                            <Columns>
                                <asp:CommandField ShowEditButton="True"  EditImageUrl="/Images/UI/edituser.jpg" 
                                    ButtonType="Image" HeaderText="Edit" />
                                <asp:CommandField ShowDeleteButton="True" 
                                    DeleteImageUrl="/Images/UI/deleteuser.jpg" ButtonType="Image" 
                                    HeaderText="Delete"/>
                            </Columns>
                            <HeaderStyle BackColor="#CCCCCC" ForeColor="White" />
                        </asp:GridView>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                            SelectCommand="SELECT [UserName], [UserId], [IsAnonymous], [LastActivityDate] FROM [vw_aspnet_Users]"
                            DeleteCommand="DELETE FROM [vw_aspnet_Users] WHERE Userid=?"
                            UpdateCommand=" UPDATE [vw_aspnet_Users] SET UserName=@UserName where Userid=?"
                            >
                                                        
                        </asp:SqlDataSource>
</div>
<div id="dvArticle" style="display: none;">
    <a style="font-size:large; color:Gray; text-align:center; ">Edit/Delete Articles</a>
                    <asp:GridView ID="gvArticles" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ActionID" 
                        DataSourceID="SqlDataSource2" Width="1074px">
                        <Columns>
                            <asp:CommandField HeaderText="Edit" ShowEditButton="True" EditImageUrl="/Images/UI/EditArticle.jpg" ButtonType="Image" />
                            <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" DeleteImageUrl="/Images/UI/DeleteArticle.jpg" ButtonType="Image" />
                            <asp:BoundField DataField="UserID_FK" HeaderText="UserID"  ReadOnly="true"
                                SortExpression="UserID_FK" />
                            <asp:BoundField DataField="ActionID" HeaderText="ID" 
                                InsertVisible="False" ReadOnly="True" SortExpression="ActionID" />
                            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                            <%--<asp:BoundField DataField="Description" HeaderText="Description" 
                                SortExpression="Description" />--%>
                                <asp:TemplateField HeaderText="Description">

                                <EditItemTemplate>
                                    <asp:TextBox ID="CategoryNameTextBox"  Width="700px" TextMode="MultiLine" runat="server" Text='<%# Bind("Description") %>'>
                                    </asp:TextBox><br />
                                </EditItemTemplate>
                                <ItemTemplate>
                                    
                               <asp:Label ID="lbl1" Width="700px" runat="server" Text='<%# Bind("Description")%>' /> 
                                </ItemTemplate>
                                 <ItemStyle Width="100px" />
                                  </asp:TemplateField>

                            <asp:BoundField DataField="AddedDate" HeaderText="AddDate" ReadOnly="true"
                                SortExpression="AddedDate" />
                            <asp:BoundField DataField="Count_page" HeaderText="Visits" ReadOnly="true"
                                SortExpression="Count_page" />
                        </Columns>
                        <HeaderStyle BackColor="#CCCCCC" ForeColor="White" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                        SelectCommand="SELECT [UserID_FK], [ActionID], [Title], [Description], [Image], [AddedDate], [Count_page] FROM [MasterTable]"
                         UpdateCommand="Update [MasterTable] set [Title]= @Title , [Description] = @Description , [AddedDate] = @AddedDate WHERE (ActionID=@ActionID) "
                         DeleteCommand="Delete from [MasterTable] where (ActionID=@ActionID)" 
                        >
                    </asp:SqlDataSource>
</div>
<div id="dvPermissions" style="display: none;">
    <a style="font-size:large; color:Gray; text-align:center; ">Edit Permissions</a>
                    <asp:GridView ID="gvPermissions" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" 
                        DataSourceID="SqlDataSource3" DataKeyNames="UserID_FK">
                        <Columns>
                            <asp:CommandField ShowEditButton="True" />
                            <asp:CommandField ShowDeleteButton="True" />
                            <asp:BoundField DataField="UserID_FK" HeaderText="UserID_FK" 
                                SortExpression="UserID_FK" />
                            <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                                SortExpression="FirstName" />
                            <asp:BoundField DataField="LastName" HeaderText="LastName" 
                                SortExpression="LastName" />
<%--                            <asp:BoundField DataField="MembershipType" HeaderText="MembershipType" 
                                SortExpression="MembershipType" />--%>
                                <asp:TemplateField HeaderText="MembershipType">
                                          
                                <EditItemTemplate>
                                    <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true" DataValueField="MembershipType"
                                     SelectedValue='<%# Bind("MembershipType")%>' DataSourceID="SqlDataSource3" >
                                        
                                    </asp:DropDownList>
                                     <asp:SqlDataSource ID="SqlDataSource3" runat="server"
                                     ConnectionString="<%$ ConnectionStrings:Connectionstring %>" 
                                     ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                                     SelectCommand="Select MembershipType from MembersType"
                                     ></asp:SqlDataSource>
                                </EditItemTemplate>
                                 <ItemTemplate>
                                    
                               <asp:Label ID="lbl1" runat="server" Text='<%# Bind("MembershipType")%>' /> 
                                </ItemTemplate>
                                 <ItemStyle Width="100px" />
                                  </asp:TemplateField>
                            <asp:BoundField DataField="Country" HeaderText="Country" 
                                SortExpression="Country" />
                            <asp:BoundField DataField="Occupation" HeaderText="Occupation" 
                                SortExpression="Occupation" />
                            <asp:BoundField DataField="AboutUser" HeaderText="AboutUser" 
                                SortExpression="AboutUser" />
                            <asp:BoundField DataField="Occ_Desc" HeaderText="Occ_Desc" 
                                SortExpression="Occ_Desc" />
                        </Columns>
                    </asp:GridView>
                
                    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                        SelectCommand="SELECT UD.UserID_FK, UD.FirstName, UD.LastName, MT.MembershipType, UD.Country, UD.Occupation, UD.AboutUser, UD.Occ_Desc FROM (UserDetails UD INNER JOIN MembersType MT ON UD.MembershipID_Fk = MT.MembershipID)"
                        UpdateCommand="Update [UserDetails] set [MembershipID_FK]= @MembershipID_FK WHERE (ID=@ID) "
                         DeleteCommand="Delete from [UserDetails] WHERE ID=?" >
                    </asp:SqlDataSource>

</div>

<div id="dvComments" style="display: none;">
    <a style="font-size:large; color:Gray; text-align:center; ">Edit/Delete Comments</a>
                    <asp:GridView ID="gvComments" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" 
                        DataSourceID="SqlDataSource4" DataKeyNames="ID">
                        <Columns>
                            <asp:CommandField ShowEditButton="True" />
                            <asp:CommandField ShowDeleteButton="True" />
                            <asp:BoundField DataField="author" HeaderText="author" 
                                SortExpression="author" />
                            <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
                            <asp:BoundField DataField="comments" HeaderText="comments" 
                                SortExpression="comments" />
                            <asp:BoundField DataField="actionID" HeaderText="actionID" 
                                SortExpression="actionID" />
                        </Columns>
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                        SelectCommand="SELECT [ID],[author], [title], [comments], [actionID] FROM [Postings]"
                        UpdateCommand="UPDATE [Postings] set [title]=@title where ID=?"
                        DeleteCommand="DELETE FROM [Postings] WHERE ID=?"
                        >
                    </asp:SqlDataSource>

</div>
    </form>
        </td>
    </tr>

</asp:Content>
